package com.commerceerp.system.controller;

import com.commerceerp.system.entity.*;
import com.commerceerp.system.service.FactoryService;
import com.commerceerp.system.util.ApiResult;
import com.commerceerp.system.util.DateUtil;
import com.commerceerp.system.util.RdPage;
import com.commerceerp.system.util.StringUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@Api(description = "仓库接口", value = "仓库接口")
@Scope("prototype")
@RestController
@EnableAutoConfiguration
public class FactoryController {

    @Autowired
    private FactoryService factoryService;

    @ApiOperation(value = "获取商品信息列表")
    @ApiImplicitParams({

            @ApiImplicitParam(paramType = "query", name = "type", value = "搜索类型（1:商品SKU,2:平台SKU,3:商品名称）", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "content", value = "搜索内容", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodClass", value = "产品类型", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodSellType", value = "销售方式(1:商品,2:赠品,3:包材)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodCreateTimePX", value = "创建时间排序（1:正序,2:反序）", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "goodUpdTimePX", value = "更新时间排序（1:正序,l2：反序）", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "goodSystemSkuPX", value = "商品sku排序（1:正序,l2：反序）", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "goodPurchasePricePX", value = "商品参考价（1:正序,l2：反序）", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "current", value = "当前页", required = true, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "记录数", required = true, dataType = "Integer")
    })
    @RequestMapping(value = "/getAllSystemGood", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getAllSystemGood(String type,String content,String goodClass,String goodSellType,Integer goodCreateTimePX,
                                      Integer goodUpdTimePX,Integer goodSystemSkuPX,Integer goodPurchasePricePX,Integer current,
                                      Integer pageSize,String goodSku) throws IOException {


        PageHelper.startPage(Integer.valueOf(current), Integer.valueOf(pageSize));

        String goodPlatformSku = null;
        String goodSystemSku = null;
        String goodSystemChname = null;

        if("1".equals(type)){
            goodSystemSku = content;
        } else if ("2".equals(type)){
            goodPlatformSku = content;
        } else if("3".equals(type)){
            goodSystemChname = content;
        }
        if(StringUtils.isNotEmpty(goodSku)){
            goodSystemSku = goodSku;
        }

        System.out.println("---------------");

        List<Map> goodsInfoList = factoryService.getAllSystemGood(goodPlatformSku,goodSystemSku,goodSystemChname,goodClass,goodSellType,goodCreateTimePX,goodUpdTimePX,goodSystemSkuPX,goodPurchasePricePX);

        //获取分页信息
        PageInfo<Map> pageInfo = new PageInfo<>(goodsInfoList);
        RdPage rdPage = RdPage.getPageInfo(pageInfo, String.valueOf(current), String.valueOf(pageSize));

        return  new ApiResult(Constant.SUCCEED_CODE_VALUE,"成功",goodsInfoList,rdPage);
    }

    @ApiOperation(value = "新增系统商品信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "goodSystemEnname", value = "英文名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodSystemChname", value = "中文名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodPicPath", value = "图片地址", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodStorehouseIds", value = "仓库id(如：1,2)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodSellType", value = "销售方式(1:商品,2:赠品,3:包材)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodClass", value = "产品分类", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodPurchasePrice", value = "商品参考价", required = false, dataType = "Double"),
            @ApiImplicitParam(paramType = "query", name = "goodState", value = "产品状态", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodWeight", value = "产品重量", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodSize", value = "产品尺寸", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodPlatformSku", value = "平台商品sku", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodSystemSku", value = "系统商品sku", required = true, dataType = "String")
    })
    @RequestMapping(value = "/saveNewSystemGood", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult saveNewSystemGood(@RequestParam(value = "goodSystemEnname", required = false) String goodSystemEnname,
                                        @RequestParam(value = "goodSystemChname", required = false) String goodSystemChname,
                                        @RequestParam(value = "goodPicPath", required = false) String goodPicPath,
                                        @RequestParam(value = "goodStorehouseIds", required = false) String goodStorehouseIds,
                                        @RequestParam(value = "goodSellType", required = false) String goodSellType,
                                        @RequestParam(value = "goodClass", required = false) String goodClass,
                                        @RequestParam(value = "goodPurchasePrice", required = false) Double goodPurchasePrice,
                                        @RequestParam(value = "goodState", required = false) String goodState,
                                        @RequestParam(value = "goodWeight", required = false) String goodWeight,
                                        @RequestParam(value = "goodSize", required = false) String goodSize,
                                        @RequestParam(value = "goodPlatformSku", required = true) String goodPlatformSku,
                                        @RequestParam(value = "goodSystemSku", required = true) String goodSystemSku) throws IOException {


            Integer flag = 0;

            GoodInfo goodInfo = new GoodInfo();
            goodInfo.setGoodSystemEnname(goodSystemEnname);
            goodInfo.setGoodSystemChname(goodSystemChname);
            goodInfo.setGoodPicPath(goodPicPath);
            goodInfo.setGoodStorehouseId(goodStorehouseIds);
            goodInfo.setGoodSellType(goodSellType);
            goodInfo.setGoodClass(goodClass);
            goodInfo.setGoodPurchasePrice(goodPurchasePrice);
            goodInfo.setGoodState(goodState);
            goodInfo.setGoodWeight(goodWeight);
            goodInfo.setGoodSize(goodSize);
            goodInfo.setGoodPlatformSku(goodPlatformSku);
            goodInfo.setGoodSystemSku(goodSystemSku);

            flag = factoryService.saveNewSystemGood(goodInfo);

        if(flag != 0){
            return new ApiResult(200,"");
        }else{
            return new ApiResult(405,"");
        }
    }


    @ApiOperation(value = "获取仓库清单列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "gsStorehouseId", value = "仓库id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodSystemChname", value = "商品名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodSystemSku", value = "商品sku", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodSellType", value = "销售方式(1:商品,2:赠品,3:包材)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "gsCreateTimePX", value = "创建时间排序（1:正序,2:反序）", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "gsUpdTimePX", value = "更新时间排序（1:正序,l2：反序）", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "gsGoodSkuPX", value = "商品sku（1:正序,l2：反序）", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "gsAllNumberPX", value = "商品库存量（1:正序,l2：反序）", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "current", value = "当前页", required = true, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "记录数", required = true, dataType = "Integer")
    })
    @RequestMapping(value = "/getAllGoodStorehouseInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getAllGoodStorehouseInfo(@RequestParam(value = "gsStorehouseId", required = false) String gsStorehouseId,
                                              @RequestParam(value = "goodSystemChname", required = false) String goodSystemChname,
                                              @RequestParam(value = "goodSystemSku", required = false) String goodSystemSku,
                                              @RequestParam(value = "goodSellType", required = false) String goodSellType,
                                              @RequestParam(value = "gsCreateTimePX", required = false) Integer gsCreateTimePX,
                                              @RequestParam(value = "gsUpdTimePX", required = false) Integer gsUpdTimePX,
                                              @RequestParam(value = "gsGoodSkuPX", required = false) Integer gsGoodSkuPX,
                                              @RequestParam(value = "gsAllNumberPX", required = false) Integer gsAllNumberPX,
                                              @RequestParam(value = "current") Integer current,
                                              @RequestParam(value = "pageSize") Integer pageSize) throws IOException {


        List<Map> gsList = factoryService.getAllGoodStorehouseInfo(gsStorehouseId,  goodSystemChname,  goodSystemSku,  goodSellType,  gsCreateTimePX,  gsUpdTimePX,  gsGoodSkuPX,  gsAllNumberPX);

        PageHelper.startPage(Integer.valueOf(current), Integer.valueOf(pageSize));

        //获取分页信息
        PageInfo<Map> pageInfo = new PageInfo<>(gsList);
        RdPage rdPage = RdPage.getPageInfo(pageInfo, String.valueOf(current), String.valueOf(pageSize));

        return new ApiResult(Constant.SUCCEED_CODE_VALUE,"查询成功",gsList,rdPage);
    }


    @ApiOperation(value = "更新商品的仓库清单")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "gsId", value = "商品仓库id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "gsAllNumber", value = "商品库存量", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "gsSafeNumber", value = "商品安全库存量", required = false, dataType = "Integer"),
            @ApiImplicitParam(paramType = "query", name = "gsGoodPrice", value = "商品单价", required = false, dataType = "Double"),
            @ApiImplicitParam(paramType = "query", name = "gsRemark", value = "备注", required = false, dataType = "String")
    })
    @RequestMapping(value = "/updGoodStorehouseInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult updGoodStorehouseInfo(@RequestParam(value = "gsId", required = false) String gsId,
                                            @RequestParam(value = "gsAllNumber", required = false) Integer gsAllNumber,
                                           @RequestParam(value = "gsSafeNumber", required = false) Integer gsSafeNumber,
                                            @RequestParam(value = "gsGoodPrice", required = false) Double gsGoodPrice,
                                            @RequestParam(value = "gsRemark", required = false) String gsRemark) throws IOException {

        GoodStorehouseInfo gs = new GoodStorehouseInfo();
        gs.setGsAllNumber(gsAllNumber);
        gs.setGsGoodPrice(gsGoodPrice);
        gs.setGsRemark(gsRemark);
        gs.setGsId(gsId);
        gs.setGsSafeNumber(gsSafeNumber);

        Integer success = factoryService.updGoodStorehouseInfo(gs);

        if(success == 1){
            return new ApiResult<>(Constant.SUCCEED_CODE_VALUE,Constant.OPERATION_SUCCESS,null,null);
        }else{
            return new ApiResult<>(Constant.FAIL_CODE_VALUE,Constant.OPERATION_FAIL,null,null);

        }
    }


    @ApiOperation(value = "获取仓库信息列表")
    @ApiImplicitParams({

    })
    @RequestMapping(value = "/getAllStorehouseInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getAllStorehouseInfo() throws IOException {

        List<StorehouseInfo> storehouseInfos = factoryService.getAllStorehouseInfo();

        return  new ApiResult(Constant.SUCCEED_CODE_VALUE,"成功",storehouseInfos,null);

    }



    @ApiOperation(value = "新增仓库信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "storehouseName", value = "仓库名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "storehouseResponsibleMan", value = "负责人", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "storehousePhone", value = "联系方式", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "storehouseQq", value = "qq", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "storehouseEmail", value = "email", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "storehousePostcode", value = "邮编", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "storehouseProvince", value = "省", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "storehouseCity", value = "市", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "storehouseArea", value = "区", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "storehouseDetailAddress", value = "详细地址", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "storehouseRemark", value = "备注", required = false, dataType = "String")
    })
    @RequestMapping(value = "/saveNewStorehouseInfo", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult saveNewStorehouseInfo(@RequestParam(value = "storehouseName", required = false) String storehouseName,
                                            @RequestParam(value = "storehouseResponsibleMan", required = false) String storehouseResponsibleMan,
                                            @RequestParam(value = "storehousePhone", required = false) String storehousePhone,
                                            @RequestParam(value = "storehouseQq", required = false) String storehouseQq,
                                            @RequestParam(value = "storehouseEmail", required = false) String storehouseEmail,
                                            @RequestParam(value = "storehousePostcode", required = false) String storehousePostcode,
                                            @RequestParam(value = "storehouseProvince", required = false) String storehouseProvince,
                                            @RequestParam(value = "storehouseCity", required = false) String storehouseCity,
                                            @RequestParam(value = "storehouseArea", required = false) String storehouseArea,
                                            @RequestParam(value = "storehouseDetailAddress", required = false) String storehouseDetailAddress,
                                            @RequestParam(value = "storehouseRemark", required = false) String storehouseRemark) throws IOException {


        StorehouseInfo storehouseInfo = new StorehouseInfo();
        storehouseInfo.setStorehouseArea(storehouseArea);
        storehouseInfo.setStorehouseCity(storehouseCity);
        storehouseInfo.setStorehouseArea(storehouseArea);
        storehouseInfo.setStorehouseDetailAddress(storehouseDetailAddress);
        storehouseInfo.setStorehouseEmail(storehouseEmail);
        storehouseInfo.setStorehousePhone(storehousePhone);
        storehouseInfo.setStorehouseProvince(storehouseProvince);
        storehouseInfo.setStorehouseResponsibleMan(storehouseResponsibleMan);
        storehouseInfo.setStorehouseRemark(storehouseRemark);
        storehouseInfo.setStorehouseName(storehouseName);
        storehouseInfo.setStorehouseQq(storehouseQq);
        storehouseInfo.setStorehousePostcode(storehousePostcode);

        Integer success = factoryService.saveNewStorehouseInfo(storehouseInfo);

        if(success == 1){
            return new ApiResult<>(Constant.SUCCEED_CODE_VALUE,Constant.OPERATION_SUCCESS,null,null);
        }else{
            return new ApiResult<>(Constant.FAIL_CODE_VALUE,Constant.OPERATION_FAIL,null,null);
        }
    }


    @ApiOperation(value = "将平台sku绑定到系统商品")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "goodId", value = "商品Id,如(1，2)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodPlatformSku", value = "平台商品sku,如(1，2)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodPlatformType", value = "商品sku平台类型(1:eaby,2:amazon,3:wish)", required = false, dataType = "goodPlatformType")
    })
    @RequestMapping(value = "/updPlatformSkuToGood", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult updPlatformSkuToGood(@RequestParam(value = "goodId", required = false) String goodId,
                                            @RequestParam(value = "goodPlatformSku", required = false) String goodPlatformSku,
                                           @RequestParam(value = "goodPlatformType", required = false) String goodPlatformType) throws IOException {


        String[] goodIds = goodId.split(",");
        String[] goodPlatformSkus = goodPlatformSku.split(",");
        String[] goodPlatformTypes = goodPlatformType.split(",");

        for(int i=0 ;i<goodIds.length ; i++){
            String id = goodIds[i];
            String sku = goodPlatformSkus[i];
            String type = goodPlatformTypes[i];

            factoryService.updPlatformSkuToGood(id,sku,type);
        }

            return new ApiResult<>(Constant.SUCCEED_CODE_VALUE,Constant.OPERATION_SUCCESS,null,null);

    }


    @ApiOperation(value = "获取商品绑定下拉菜单为绑定系统商品")
    @ApiImplicitParams({

    })
    @RequestMapping(value = "/getNoBundingSystemSku", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getNoBundingSystemSku() throws IOException {


        List<GoodInfo> list = factoryService.getNoBundingSystemSku();

        return new ApiResult(Constant.SUCCEED_CODE_VALUE,"成功",list,null);

    }


    @ApiOperation(value = "根据系统商品id查找商品信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "goodId", value = "商品Id", required = false, dataType = "String")
    })
    @RequestMapping(value = "/getGoodInfoByGoodId", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getGoodInfoByGoodId(@RequestParam(value = "goodId", required = false) String goodId) throws IOException {

         Map<String,Object> map = factoryService.getGoodInfoByGoodId(goodId);

         return new ApiResult(Constant.SUCCEED_CODE_VALUE,"成功",map,null);
    }


    @ApiOperation(value = "编辑系统商品")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "goodId", value = "商品Id", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodSystemSku", value = "系统sku", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodSellType", value = "商品销售方式(1:商品,2:赠品,3:包材)", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodClass", value = "商品类型", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodSystemChname", value = "商品中文名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodSystemEnname", value = "商品英文名称", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodPlatformSku", value = "商品平台sku", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "goodStorehouseId", value = "商品仓库id,如：(1,2)", required = false, dataType = "String")
    })
    @RequestMapping(value = "/updSystemGoodInfoById", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult updSystemGoodInfoById(@RequestParam(value = "goodId", required = false) String goodId,
                                           @RequestParam(value = "goodSystemSku", required = false) String goodSystemSku,
                                           @RequestParam(value = "goodSellType", required = false) String goodSellType,
                                           @RequestParam(value = "goodClass", required = false) String goodClass,
                                           @RequestParam(value = "goodSystemChname", required = false) String goodSystemChname,
                                           @RequestParam(value = "goodSystemEnname", required = false) String goodSystemEnname,
                                           @RequestParam(value = "goodPlatformSku", required = false) String goodPlatformSku,
                                           @RequestParam(value = "goodStorehouseId", required = false) String goodStorehouseId) throws IOException {


        ApiResult apiResult = null;

        GoodInfo goodInfo = new GoodInfo();
        goodInfo.setGoodId(goodId);
        goodInfo.setGoodSystemSku(goodSystemSku);
        goodInfo.setGoodSellType(goodSellType);
        goodInfo.setGoodClass(goodClass);
        goodInfo.setGoodSystemChname(goodSystemChname);
        goodInfo.setGoodSystemEnname(goodSystemEnname);
        goodInfo.setGoodPlatformSku(goodPlatformSku);
        goodInfo.setGoodStorehouseId(goodStorehouseId);

        Integer success = factoryService.updSystemGoodInfoById(goodInfo);

        if(success == 1){
            apiResult = new ApiResult(Constant.SUCCEED_CODE_VALUE,Constant.OPERATION_SUCCESS,null,null);
        }else{
            apiResult = new ApiResult(Constant.FAIL_CODE_VALUE,Constant.OPERATION_FAIL,null,null);
        }
        return apiResult;
    }


    @ApiOperation(value = "删除系统商品信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "goodId", value = "商品Id", required = false, dataType = "String")
    })
    @RequestMapping(value = "/delSystemGoodInfoById", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult delSystemGoodInfoById(@RequestParam(value = "goodId", required = false) String goodId) throws IOException {

        Integer success = factoryService.delSystemGoodInfoById(goodId);

        if(success == 1){
            return new ApiResult(Constant.SUCCEED_CODE_VALUE,Constant.OPERATION_SUCCESS,null,null);
        }else if(success == 0){
            return new ApiResult(Constant.FAIL_CODE_VALUE,Constant.OPERATION_FAIL,null,null);
        }else if(success == -1){
            return new ApiResult(Constant.UNKNOW_CODE_VALUE,Constant.OPERATION_UNKONW_FAIL,null,null);
        }
        return  null;
    }

    @ApiOperation(value = "新增商品类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "className", value = "类别名称,如(XX,XX)", required = false, dataType = "String")
    })
    @RequestMapping(value = "/saveGoodClass", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult saveGoodClass(@RequestParam(value = "className", required = false) String className) throws IOException {

        String[] classNames = className.split(",");
        for(String name : classNames){
            GoodClassInfo goodClassInfo = new GoodClassInfo();
            goodClassInfo.setClassName(name);
            goodClassInfo.setClassCreateTime(DateUtil.getYMDHMSDate());

            factoryService.saveGoodClass(goodClassInfo);
        }
            return new ApiResult(Constant.SUCCEED_CODE_VALUE,Constant.OPERATION_SUCCESS,null,null);
    }


    @ApiOperation(value = "查询所有类型")
    @ApiImplicitParams({

    })
    @RequestMapping(value = "/getAllGoodClass", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult getAllGoodClass() throws IOException {

        List<Map> list= factoryService.getAllGoodClass();

        return new ApiResult(Constant.SUCCEED_CODE_VALUE,Constant.OPERATION_SUCCESS,list,null);

    }


    @ApiOperation(value = "编辑商品类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "classIdAndNames", value = "类别id和名字，如(1_XX,2_xx)", required = false, dataType = "String")
    })
    @RequestMapping(value = "/updGoodClass", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult updGoodClass(@RequestParam(value = "classIdAndNames", required = false) String classIdAndNames) throws IOException {

        Integer success = factoryService.updGoodClass(classIdAndNames);

        if(success == 1){
            return new ApiResult(Constant.SUCCEED_CODE_VALUE,Constant.OPERATION_SUCCESS,null,null);
        }else{
            return new ApiResult(Constant.FAIL_CODE_VALUE,Constant.OPERATION_FAIL,null,null);
        }
    }

    @ApiOperation(value = "删除商品类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "classId", value = "类别id，如(1,2)", required = false, dataType = "String")
    })
    @RequestMapping(value = "/delGoodClass", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult delGoodClass(@RequestParam(value = "classId", required = false) String classId) throws IOException {

        Integer success = factoryService.delGoodClass(classId);

        if(success == 1){
            return new ApiResult(Constant.SUCCEED_CODE_VALUE,Constant.OPERATION_SUCCESS,null,null);
        }else{
            return new ApiResult(Constant.FAIL_CODE_VALUE,Constant.OPERATION_FAIL,null,null);
        }
    }


    @ApiOperation(value = "删除仓库信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "storehouseId", value = "仓库id", required = false, dataType = "String")
    })
    @RequestMapping(value = "/delStorehouseById", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult delStorehouseById(@RequestParam(value = "storehouseId", required = false) String storehouseId) throws IOException {

        Integer success = factoryService.delStorehouseById(storehouseId);

        if(success == 1){
            return new ApiResult(Constant.SUCCEED_CODE_VALUE,Constant.OPERATION_SUCCESS,null,null);
        }else{
            return new ApiResult(Constant.FAIL_CODE_VALUE,Constant.OPERATION_FAIL,null,null);
        }
    }



}
